<div class="col-xs-12 info-center">
    <ol class="breadcrumb" >
        <li> <i class="fa fa-anchor"></i>
            &nbsp;权限管理
        </li>
        <li>管理员列表</li>
    </ol>
    <div class="bs-callout bs-callout-warning">
        <h4>
            系统使用单位: <strong>{:C('COLLEGE_NAME')}</strong>
        </h4>
    </div>
</div>

<div class="col-xs-12 info-center">

    <div class="panel panel-mcit">

        <div class="panel-heading" > <i class="fa fa-list"></i>
            &nbsp;&nbsp;用户列表 &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            <a href="__URL__/role" style="color: #ffffff"><i class="fa fa-users"></i>&nbsp;&nbsp;<b>角色权限管理</b></a>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            <a href="__URL__/addUser" style="color: #ffffff"><i class="glyphicon glyphicon-user"></i>&nbsp;&nbsp;<b>添加用户</b></a>

        </div>
        <table class="table table-bordered table-striped table-mcit">
            <thead>
                <tr>
                    <th>
                        <a class='btn btn-block btn-mcit' disabled>姓名</a>
                    </th>
                    <th>
                        <a class='btn btn-block btn-mcit' disabled>账号</a>
                    </th>
                    <th>
                        <a class='btn btn-block btn-mcit' disabled>角色</a>
                    </th>
                    <th>
                        <a class='btn btn-block btn-mcit' disabled>公司名称</a>
                    </th>
                    <th width="20%">
                        <a class='btn btn-block btn-mcit' disabled>操作</a>
                    </th>
                </tr>
            </thead>
            <tbody id="DataTableContent">
                <empty name="user">
                    <td colspan="99" style="text-align:center" class="danger"> <strong><i class="fa fa-meh-o"></i>
                            &nbsp;&nbsp;当前条件下没有数据</strong> 
                    </td>
                    <else />
                    <volist name="user" id="data">
                        <if condition="$data.id eq $newid">
                            <tr class="danger">
                        <else/>
                            <tr>
                        </if>
                            <td>
                                <p class="mcit-table-p">{$data.name}</p>
                            </td>
                            <td>
                                <p class="mcit-table-p">{$data.account}</p>
                            </td>
                            <td>
                                <p class="mcit-table-p">{$data.roleName}</p>
                            </td>
                            <td>
                                <p class="mcit-table-p">{$data.company}</p>
                            </td>
                            <td>
                                <a class="btn btn-sm btn-warning" href="__URL__/editUser/id/{$data.id}">
                                <!--<a class="btn btn-sm btn-warning" href={$data.id|mcitUrl = ###,'edit_user'}>-->
                                <i class="fa fa-edit"></i>
                                    &nbsp;修改账号
                                </a>
                                <a class="btn btn-sm btn-danger del_role" data-id="{$data.id}">
                                    <i class="fa fa-trash-o"></i>
                                    &nbsp;删除账号
                                </a>
                            </td>
                        </tr>
                    </volist>
                </empty>

                <tr>
                    <td colspan="99" style="text-align:center">
                        <ul class="pagination">{$pageView}</ul>
                    </td>
                </tr>
            </tbody>
        </table>

    </div>

</div>
<script type="text/javascript">
    $("#DataTableContent").on("click",'.del_role',function(){
        var id = $(this).attr('data-id');
        alertify.confirm("确定要删除此账号？", function (e) {
            if (e) {
                $.ajax({
                    type: "POST",
                    url:  '{:U("auth/delUser")}',
                    data: {id:id},
                    dataType: "json",
                    success: function(data){
                        if(data.state==100){
                            alertify.success(data.msg);
                            location.reload(true);
                        }else{
                            alertify.error(data.msg);
                        }
                    }
                });
            } else {
                alertify.error("取消操作！");
            }
        }, "mcit_default");
    });
    $("#add_role").ajaxForm({
        dataType:'json',
        clearForm:true,
        beforeSubmit:function(){
            if($("#name").val()==''){
                alertify.error("请填写要添加的角色名称");
                return false;
            }
            return true
        },
        success:function(data){
            if(data.state==100){
                alertify.success(data.msg);
                location.href = data.url;
            }else{
                alertify.error(data.msg);
            }
        }
    });
</script>